import pygame
image=pygame.image.load("plank.jpg")
image.set_colorkey((137,44,75))
import HorizontalPlatform

class Plank(HorizontalPlatform.HorizontalPlatform):
	def __init__(self,pos=(0,0),im=image,width=250):
		HorizontalPlatform.HorizontalPlatform.__init__(self,pos,im)
		self.image=pygame.transform.scale(im,(int(width),im.get_height()))
	def within_x_boundary(self,ox,ow):
		return HorizontalPlatform.HorizontalPlatform.within_x_boundary(self,ox,ow,k=0.0)
	def xLanding(self,objecto):
		pass
	def hasFallenOff_y(self,objecto):
		if self.disbalanced(objecto):
			#print '1'
			self.unbound(objecto)
			objecto.y=objecto.y-1.5*objecto.getHeight()-1
			objecto.prev_y=objecto.y
		else:
			HorizontalPlatform.HorizontalPlatform.hasFallenOff_y(self,objecto)
	def disbalanced(self,objecto):
		import Character
		import random
		if objecto.currentState==Character.ON_GROUND_WALKING:
			ag=objecto.getAgility()
			if ag<=0:
				ag=1
			b=objecto.getMass()*objecto.inStateFor/ag
			return random.randint(0,b)>100
		return False
	def lowerCondition(self,objecto):
		return False